package util.level;

import java.util.*;
import org.newdawn.slick.Graphics;

public class TileGroup
{
	private ArrayList<TileLayer> layers;
	private HashMap<String,TileLayer> layerMap;
	
	/**
	 * Ordered list of tile layers in which to render.
	 */
	protected TileGroup()
	{
		layers=new ArrayList<TileLayer>();
		layerMap=new HashMap<String,TileLayer>();
	}
	
	/**
	 * Adds the layer to the group.
	 * @param layer - layer to add on the group.
	 */
	public void addLayer(TileLayer layer)
	{
		layerMap.put(layer.getName(),layer);
		layers.add(layer);
	}
	
	public TileLayer findLayer(String name)
	{
		return layerMap.get(name);
	}
	
	public void render(Graphics g)
	{
		for(TileLayer l:layers)
			l.render(g);
	}
}
